# proto-file: mediapipe/framework/calculator.proto
# proto-message: CalculatorGraphConfig

node {
  calculator: "ClassMappingsSidePacketCalculator"
  output_side_packet: "CLASS_MAPPINGS_PROVIDER:string_label_mapping_provider"
  options {
    [ambient_sensing.ClassMappingsSidePacketCalculatorOptions.ext] {
      mapping_type: STRING_CLASS
      % for (label_mapping_file : label_mapping_files) %
      label_mapping_files: %label_mapping_file%
      %end%
    }
  }
}

node {
  calculator: "FilterAnnotatedRecordingCollectionCalculator"
  input_side_packet: "INPUT_ANNOTATED_RECORDING_COLLECTION:input"
  output_stream: "FILTERED_ANNOTATED_RECORDING_COLLECTION:intermediate_filter"
  options {
    [ambient_sensing.FilterAnnotatedRecordingCollectionCalculatorOptions.ext] {
      filter_if_sensor_not_present_or_empty: "ACCELEROMETER"
      % for (exclude_user_id : exclude_user_ids) %
      exclude_user_id: %exclude_user_id%
      %end%
      % for (exclude_session_activity : exclude_session_activities) %
      exclude_session_activity: %exclude_session_activity%
      %end%
      % for (include_session_activity : include_session_activities) %
      include_session_activity: %include_session_activity%
      %end%
      % for (substring : at_least_one_annotation_with_substring) %
      at_least_one_annotation_with_substring: %substring%
      %end%
      % for (substring : no_annotations_with_substring) %
      no_annotations_with_substring: %substring%
      %end%
    }
  }
}

node {
  calculator: "AddClassMappingsCalculator"
  input_stream: "INPUT_ANNOTATED_RECORDING_COLLECTION:intermediate_filter"
  input_side_packet: "CLASS_MAPPINGS_PROVIDER:string_label_mapping_provider"
  output_stream: "OUTPUT_ANNOTATED_RECORDING_COLLECTION:label_mapped_recording_collection"
}

node {
  calculator: "FilterAnnotatedRecordingCollectionCalculator"
  input_stream: "INPUT_ANNOTATED_RECORDING_COLLECTION:label_mapped_recording_collection"
  output_stream: "FILTERED_ANNOTATED_RECORDING_COLLECTION:prefiltered_output"
  options {
    [ambient_sensing.FilterAnnotatedRecordingCollectionCalculatorOptions.ext] {
      filter_label_mapping_name: %filter_label_mapping_name%
      % for (exclude_class_name : exclude_class_names) %
      exclude_class_name: %exclude_class_name%
      %end%
      % for (include_class_name : include_class_names) %
      include_class_name: %include_class_name%
      %end%
    }
  }
}

node {
  calculator: "ExtractSensorDataFromAnnotatedRecordingCollectionCalculator"
  input_stream: "INPUT_ANNOTATED_RECORDING_COLLECTION:prefiltered_output"
  output_stream: "OUTPUT_DATA_STREAM:0:accel_data"
  options {
    [ambient_sensing.ExtractSensorDataFromAnnotatedRecordingCollectionCalculatorOptions.ext] {
      sensor_options {
        type: "SENSOR"
        subtype: "ACCELEROMETER"
        required_dims: 3
        duplicate_timestamps_handling_strategy: RAISE_ERROR
      }
    }
  }
}

node {
  calculator: "PacketResamplerCalculator"
  input_stream: "accel_data"
  output_stream: "resampled_accel_data"
  options {
    [mediapipe.PacketResamplerCalculatorOptions.ext]: {
      frame_rate: %sampling_rate%
    }
  }
}

node {
  calculator: "WindowCalculator"
  input_stream: "INPUT_STREAM:0:resampled_accel_data"
  output_stream: "WINDOWED_VALUES_OUTPUT_STREAM:0:windowed_accel_data"
  options {
    [ambient_sensing.WindowCalculatorOptions.ext]: {
      enforce_input_dims: 3
      window_size: %window_size%
      window_stride: %window_stride%
      padding_strategy: %window_padding_strategy%
      minimum_windows: %minimum_windows%
    }
  }
}

node {
  calculator: "ComputeSampleMagnitudeVarianceCalculator"
  input_stream: "INPUT_WINDOW:windowed_accel_data"
  output_stream: "OUTPUT_VARIANCE:accel_variance"
  options {
    [ambient_sensing.ComputeSampleMagnitudeVarianceCalculatorOptions.ext] {
      window_size: %window_size%
    }
  }
}

node {
  calculator: "DropOnThresholdValueCalculator"
  input_stream: "INPUT_REFERENCE_VALUE:accel_variance"
  input_stream: "INPUT_DATA:0:windowed_accel_data"
  output_stream: "OUTPUT_DATA:0:thresholded_accel_data"
  options {
    [ambient_sensing.DropOnThresholdValueCalculatorOptions.ext] {
      threshold: %min_variance_threshold%
      drop_below_threshold: %drop_below_threshold_comparator%
      invert_threshold: %invert_threshold%
    }
  }
}

node {
  calculator: "MergeSensorDataIntoAnnotatedRecordingCollectionCalculator"
  input_stream: "INPUT_DATA_STREAM:0:resampled_accel_data"
  input_stream: "INPUT_DATA_STREAM:1:thresholded_accel_data"
  output_stream: "OUTPUT_ANNOTATED_RECORDING_COLLECTION:merged_recording_collection"
  options {
    [ambient_sensing.MergeSensorDataIntoAnnotatedRecordingCollectionCalculatorOptions.ext] {
      sensor_options {
        type: "SENSOR"
        subtype: "ACCELEROMETER"
        required_dims: 3
      }
      sensor_options {
        type: "SENSOR"
        subtype: "ACCELEROMETER_WINDOW"
        window_dims: %window_size%
        required_dims: 3
      }
    }
  }
}

node {
  calculator: "SetAnnotatedRecordingCollectionMetadataCalculator"
  input_stream: "PROCESSED_ANNOTATED_RECORDING_COLLECTION:merged_recording_collection"
  input_stream: "ORIGINAL_ANNOTATED_RECORDING_COLLECTION:prefiltered_output"
  output_stream: "OUTPUT_ANNOTATED_RECORDING_COLLECTION:output"
}

